package com.stylefeng.guns.command.impl;

import com.stylefeng.guns.command.ICommand;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.concurrent.TimeUnit;

@Slf4j
public class StopCmd extends ICommand {

    private String key;

    public StopCmd(String key) {
        this.key = key;
    }

    @Override
    public void execute() {
        try {
            Thread thread = CommandContext.getCommand(key);
            thread.interrupt();
            CommandContext.removeCommand(key);

        } catch (Exception e) {
            log.error("线程={}执行出错", Thread.currentThread().getName());
        }
    }
}
